$(document).ready(function () {
    $(".menufont span").each(function (index, value) {
        $(value).click(function () {
            $(".border").removeClass("border");
            $(this).addClass("border");
            $(".block").removeClass("block");
            $('article').children('div').eq(index).addClass("block");
            var id = $(this).attr("id");
            createCookie('showit', id, 7)
        });
    });
    var data = readCookie("showit");
    if (data == null) {
        $("#rec").click();
    } else {
        $('#' + data).click();
    }

    function createCookie(name, value, days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
    }

    function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }

    function eraseCookie(name) {
        createCookie(name, "", -1);
    }

    var swiper1 = new Swiper('.recommendlist .swiper-container', {
        paginationClickable: true,
        direction: 'vertical',
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: 2500,
        autoplayDisableOnInteraction: false
    });
    var swiper2 = new Swiper('.societylist .swiper-container', {
        paginationClickable: true,
        direction: 'vertical',
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: 2500,
        autoplayDisableOnInteraction: false
    });
});
